『Haskell in Depth』
https://gyazo.com/1b39a6b11aa0c8e40d238ccb0f55514f
2021/6/22
読むならPart3, 4辺りを読みたい
Foreword xv
Preface xvii
Acknowledgments xxiv
About This Book xxvi
About The Author xxxii
About The Cover Illustration xxxiii
PART 1 CORE HASKELL 1 (96)
1 Functions And Types 3 (15)
1.1 Solving problems in the GHCi REPL 4 (2)
with functions
1.2 From GHCi and String to GHC and Text 6 (1)
1.3 Functional programs as sets of IO 7 (3)
actions
1.4 Embracing pure functions 10 (8)
Separating I/O from pure functions 10 (3)
Computing the most frequent words by 13 (1)
sorting them
Formatting reports 14 (3)
Rule them all with IO actions 17 (1)
2 Type Classes 18 (42)
2.1 Manipulating a radar antenna with 19 (19)
type classes
The problem at hand 19 (2)
Rotating a radar antenna with Eq, Enum, 21 (5)
and Bounded
Combining turns with Semigroup and 26 (4)
Monoid
Printing and reading data with Show and 30 (3)
Read
Testing functions with Ord and Random 33 (5)
2.2 Issues with numbers and text 38 (13)
Numeric types and type classes 38 (2)
Numeric conversions 40 (1)
Computing with fixed precision 41 (2)
More about Show and Read 43 (4)
Converting recursive types to strings 47 (4)
2.3 Abstracting computations with type 51 (9)
classes
An idea of a computational context and 51 (2)
a common behavior
Exploring different contexts in parallel 53 (1)
The do notation 54 (2)
Folding and traversing 56 (4)
3 Developing An Application: Stock Quotes 60 (37)
3.1 Setting the scene 61 (7)
Inputs 62 (1)
Outputs 62 (2)
Project structure 64 (4)
3.2 Exploring design space 68 (7)
Designing the user interface 69 (1)
Dealing with input data 70 (2)
Formatting reports 72 (1)
Plotting charts 73 (1)
Project dependencies overview 74 (1)
3.3 Implementation details 75 (22)
Describing data 76 (4)
Plotting charts 80 (5)
Preparing reports 85 (7)
Implementing the user interface 92 (2)
Connecting parts 94 (3)
PART 2 INTRODUCTION TO APPLICATION DESIGN 97 (106)
4 Haskell Development Urith Modules Packages, And Projects
4.1 Organizing Haskell code with modules 100 (11)
Module structure, imports and exports, 100 (5)
and module hierarchy
Example: containers-mini 107 (4)
4.2 Understanding Haskell packages 111 (10)
Packages at the GHC level 111 (3)
Cabal packages and Hackage 114 (7)
4.3 Tools for project development 121 (11)
Dependency management 122 (5)
Haskell projects as a collection of 127 (2)
packages
Common project management activities 129 (3)
and tools
5 Monads As Practical Functionality
Providers
5.1 Basic monads in use: Maybe, Reader, 133 (14)
Writer
Maybe monad as a line saver 133 (3)
Carrying configuration all over the 136 (4)
program with Reader
Writing logs via Writer 140 (7)
5.2 Maintaining state via the State monad 147 (15)
Basic examples with the State monad 148 (4)
Parsing arithmetic expressions with 152 (8)
State
RWS monad to rule them all: The game of 160 (2)
dice
5.3 Other approaches to mutability 162 (8)
Mutable references in the IO monad 162 (4)
Mutable references in the ST monad 166 (4)
6 Structuring Programs With Monad
Transformers
6.1 The problem of combining monads 171 (8)
Evaluating expressions in reverse 171 (3)
Polish notation
Introducing monad transformers and 174 (5)
monad stacks
6.2 IO-based monad transformer stacks 179 (11)
Describing a monad stack 182 (2)
Exploiting monad stack functionality 184 (4)
Running an application 188 (1)
Can we do it without RWST? 189 (1)
6.3 What is a monad transformer? 190 (9)
Step 0 Defining a type for a transformer 191 (1)
Step 1 Turning a monad stack into a 191 (4)
monad
Step 2 Implementing the full monad 195 (2)
stack functionality
Step 3 Supplying additional 197 (1)
functionality
Using a transformer 198 (1)
6.4 Monad transformers in the Haskell 199 (4)
libraries
Identity is where it all starts 199 (1)
An overview of the most common monad 200 (3)
transformers
PART 3 QUALITY ASSURANCE 203 (138)
7 Error Handling And Logging 205 (41)
7.1 Overview of error-handling mechanisms 206 (4)
in Haskell
The idea of exceptions 206 (2)
To use or not to use? 208 (1)
Programmable exceptions vs. GHC runtime 209 (1)
exceptions
7.2 Programmable exceptions in monad 210 (6)
stacks
The Except T monad transformer 211 (1)
Example: Evaluating RPN expressions 211 (5)
7.3 GHC runtime exceptions 216 (6)
An idea of extensible exceptions 216 (2)
Throwing exceptions 218 (1)
Catching exceptions 219 (3)
7.4 Example: Accessing web APIs and GHC 222 (19)
exceptions
Application components 225 (8)
Exception-handling strategies 233 (8)
7.5 Logging 241 (5)
An overview of the monad-logger library 243 (1)
Introducing logging with monad-logger 244 (2)
into the suntimes project
8 Writing Tests 246 (35)
8.1 Setting a scene: IPv4 filtering 247 (5)
application
Development process overview 247 (1)
Initial implementation 248 (4)
8.2 Testing the IPv4 filtering application 252 (24)
Overview of approaches to testing 253 (1)
Testing Cabal projects with tasty 253 (2)
Specifications writing and checking 255 (7)
with Hspec
Property-based testing with Hedgehog 262 (10)
Golden tests with tasty-golden 272 (4)
8.3 Other approaches to testing 276 (5)
Testing functions a la the REPL with 276 (2)
doctest
Lightweight verification with Liquid 278 (1)
Haskell
Code quality with Mint 279 (2)
9 Haskell Data And Code At Run Time 281 (60)
9.1 A mental model for Haskell memory 282 (11)
usage at run time
General memory structure and closures 282 (2)
Primitive unboxed data types 284 (1)
Representing data and code in memory 285 (5)
with closures
A detour: Lifted types and the concept 290 (3)
of strictness
9.2 Control over evaluation and memory 293 (8)
usage
Controlling strictness and laziness 293 (6)
Defining data types with unboxed values 299 (2)
9.3 Exploring compiler optimizations by 301 (10)
example
Optimizing code manually 302 (6)
Looking at GHC Core 308 (2)
Benchmarking and profiling 310 (1)
10.1 Benchmarking functions with criterion 311 (16)
Benchmarking implementations of a 311 (5)
simple function
Benchmarking an IPv4 filtering 316 (11)
application
10.2 Profiling execution time and memory 327 (7)
usage
Simulating iplookup usage in the real 328 (1)
world
Analyzing execution time and memory 329 (4)
allocation
Analyzing memory usage 333 (1)
10.3 Tuning performance of the IPv4 334 (7)
filtering application
Choosing the right data structure 335 (1)
Squeezing parseIP performance 336 (5)
PART 4 ADVANCED HASKELL 341 (136)
11 Type System Advances 343 (44)
11.1 Haskell types 101 344 (12)
Terms, types, and kinds 344 (4)
Delivering information with types 348 (7)
Type operators 355 (1)
11.2 Data kinds and type-level literals 356 (6)
Promoting types to kinds and values to 356 (2)
types
Type-level literals 358 (4)
11.3 Computations over types with type 362 (10)
families
Open and closed type synonym families 362 (3)
Example: Avoid character escaping in 365 (3)
GHCi
Data families 368 (2)
Associated families 370 (2)
11.4 Generalized algebraic data types 372 (6)
Example: Representing dynamically typed 373 (3)
Example: Representing arithmetic 376 (2)
expressions with GADTs
11.5 Arbitrary-rank polymorphism 378 (5)
The meaning 378 (2)
Use cases 380 (3)
11.6 Advice on dealing with type errors 383 (4)
Be explicit about types 383 (2)
Ask the compiler 385 (1)
Saying more about errors 386 (1)
12 Metaprogramming In Haskell 387 (48)
12.1 Deriving instances 388 (13)
Basic deriving strategies 388 (5)
The problem of type safety and 393 (7)
generalized newtype deriving
Deriving by an example with Deriving Via 400 (1)
12.2 Data-type-generic programming 401 (9)
Generic data-type representation 402 (3)
Example: Generating SQL queries 405 (5)
12.3 Template Haskell and quasiquotes 410 (25)
A tutorial on Template Haskell 411 (10)
Example: Generating remote function 421 (14)
calls
13 More About Types 435 (42)
13.1 Types for specifying a web API 436 (11)
Implementing a web API from scratch 436 (9)
Implementing a web service with servant 445 (2)
13.2 Toward dependent types with 447 (30)
Safety in Haskell programs 447 (1)
Example: Unsafe interface for elevators 448 (4)
Dependent types and substituting them 452 (6)
with singletons
Example: Safe interface for elevators 458 (19)
PART 5 Haskell toolkit
14 Data-Processing Pipelines 479 (51)
14.1 Streaming data 480 (22)
General components and naive 481 (12)
implementation
The streaming package 493 (9)
14.2 Approaching an implementation of 502 (15)
pipeline stages
Reading and writing data efficiently 502 (2)
Parsing data with parser combinators 504 (5)
Accessing data with lenses 509 (8)
14.3 Example: Processing covid-19 data 517 (13)
The task 517 (2)
Processing data 519 (8)
Organizing the pipeline 527 (3)
15 Working With Relational Databases 530 (73)
15.1 Setting up an example 531 (6)
Sample database 531 (2)
Sample queries 533 (2)
Data representation in Haskell 535 (2)
15.2 Haskell database connectivity 537 (7)
Connecting to a database 537 (1)
Relating Haskell data types to database 538 (1)
types
Constructing and executing SELECT 539 (2)
queries
Manipulating data in a database 541 (1)
Solving tasks by issuing many queries 542 (2)
15.3 The postgresql-simple library 544 (3)
Connecting to a database 544 (1)
Relating Haskell data types to database 544 (1)
types
Executing queries 545 (2)
15.4 The hasql ecosystem 547 (9)
Structuring programs with hasql 547 (1)
Constructing type-safe SQL statements 548 (4)
Implementing database sessions 552 (1)
Running database sessions 553 (1)
The need for low-level operations and 554 (2)
decoding data manually
15.5 Generating SQL with opaleye 556 (12)
Structuring programs with opaleye 556 (1)
Describing database tables and their 557 (5)
fields
Writing queries 562 (2)
Running queries 564 (3)
Concurrency 567(1)
16.1 Running computations concurrently 568 (16)
An implementation of concurrency in GHC 568 (1)
Low-level concurrency with threads 569 (8)
High-level concurrency with the async 577 (7)
package
16.2 Synchronization and communication 584 (19)
Synchronized mutable variables and 585 (7)
channels
Software transactional memory (STM) 592 (11)
Appendix Further reading 603 (2)
Index 605